My file bash, and configurate for linux
sudo nano /etc/nginx/sites-available/default
location / {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# …
}
try_files $uri $uri/ =404;
systemctl restart nginx
sudo nano /etc/nginx/sites-available/default
limit_req_zone $binary_remote_addr zone=one:10m rate=30r/m;
location / {
# …
limit_req zone=one;
}
# jika lokasi spesifik seperti /admin
location /admin {
limit_req zone=one;
}
systemctl restart nginx
a2enmod ratelimit
a2enmod proxy
a2enmod proxy_http
<VirtualHost *:3000>
ServerName localhost
# Root folder
DocumentRoot /var/www/html
# Rate limiting dengan mod_ratelimit
<Location "/">
SetOutputFilter RATE_LIMIT
# Batasi kecepatan transfer menjadi 10KB per detik per koneksi
SetEnv rate-limit 1024
</Location>
# Proxy ke localhost:8000
ProxyPreserveHost On
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
# Aktifkan modul proxy dan proxy_http
ProxyRequests Off
<Proxy *>
Require all granted
</Proxy>
</VirtualHost>